<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>chunkIntoN</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const chunkIntoN = (arr, n) => {
            const size = Math.ceil(arr.length / n);
            return Array.from({ length: n }, (v, i) =>
                arr.slice(size * i, size * i + size)
            );
        };
        console.log(chunkIntoN([1, 2, 3, 4, 5, 6, 7], 4));
    </script>
</body>

</html>